

/*
function greeter(person){
    return "hello, "+person;
}
var user = "Jane User";
document.body.innerHTML = greeter(user);
*/

/*
function greeter(person: string){
    return "Hello, "+person;
}
var user = [0, 1, 2];
document.body.innerHTML = greeter(user);
*/

/*
// 与接口具有相同的内部结构，就可以实施接口
interface Person{
    firstName: string;
    lastName: string;
}
function greeter(person: Person){
    return "Hello, "+person.firstName+" "+person.lastName;
}
var user = {firstName: "Jane", lastName: "User"};
document.body.innerHTML = greeter(user);
*/

console.log('//--------------test output------------------')

    // Also of note, the use of public on arguments to the constructor is a
    // shorthand
    // that allows us to automatically create properties with that name
    // 构造函数参数加public，此类自动添加此参数名属性
    class Student {
    fullName: string;
    constructor(public firstName, public middleInitial, public lastName)
    {
        this.fullName = firstName + ' ' + middleInitial + ' ' + lastName;
    }
}

interface Person {
    firstName: string;
    lastName: string;
}
function qgreeter(person: Person)
{
    return 'Hello, ' + person.firstName + ' ' + person.lastName;
}
var user = new Student('Jane', 'M.', 'User');
// document.body.innerHTML = qgreeter(user);

console.log('//---------------test end--------------')
